package com.guigu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.DeliveryAddressMapper;
import com.guigu.pojo.DeliveryAddress;
import com.guigu.pojo.Users;
import com.guigu.service.DeliveryAddressService;
import com.guigu.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DeliveryAddressServiceimpl extends ServiceImpl<DeliveryAddressMapper, DeliveryAddress> implements DeliveryAddressService {

    @Autowired
    UsersService usersService;
    //查询商户自提地址
    @Override
    public DeliveryAddress queryByaddrsID(Integer id) {
        QueryWrapper<DeliveryAddress> queryWrapper=new QueryWrapper<DeliveryAddress>();
        //根据页面传过来的id去查询users表
        Users users=usersService.getById(id);
        System.out.println("==="+users);
        //把查询到的users对象里面的商户自提地址的id 去查询地址表
        queryWrapper.eq("id",users.getAdId());
        return this.getOne(queryWrapper);
    }
}
